#version 460 core
#include <flutter/runtime_effect.glsl>

out vec4 fragColor;

uniform vec2 iResolution;
uniform float iTime;

void main(){

    vec2 fragCoord = FlutterFragCoord().xy;
    float strength = 0.4;
    float t = iTime/3.0;

    vec3 col = vec3(0);
    vec2 fC = fragCoord;
    for(int i = -1; i <= 1; i++) {
        for(int j = -1; j <= 1; j++) {
            fC = fragCoord+vec2(i,j)/3.0;
            vec2 pos = fC/iResolution.xy;
            pos.y /= iResolution.x/iResolution.y;
            pos = 4.0*(vec2(0.5) - pos);
            for(float k = 1.0; k < 7.0; k+=1.0){
                pos.x += strength * sin(2.0*t+k*1.5 * pos.y)+t*0.5;
                pos.y += strength * cos(2.0*t+k*1.5 * pos.x);
            }
            col += 0.5 + 0.5*cos(iTime+pos.xyx+vec3(0,2,4));
        }
    }
    col /= 9.0;
    col = pow(col, vec3(0.4545));
    fragColor = vec4(col,1.0);

}
